using System;
using System.Collections;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Windows.Forms;
using MobileClient.UIProcessService;

namespace MobileClient
{
	/// <summary>
	/// Summary description for ctlNoteEntry.
	/// </summary>
	public class ctlNoteEntry : Control
	{
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
		private System.Windows.Forms.TextBox txtNote;
		private NoteEntry m_objEntry;
		private Microsoft.WindowsCE.Forms.InputPanel pnlSIP;

		public ctlNoteEntry()
		{
			// This call is required by the Windows.Forms Form Designer.
			InitializeComponent();

			m_objEntry = null;
			pnlSIP = null;
		}

		public NoteEntry Entry
		{
			get { return m_objEntry; }
			set { m_objEntry = value; }
		}

		public Microsoft.WindowsCE.Forms.InputPanel SIPPanel
		{
			get { return pnlSIP; }
			set { pnlSIP = value; }
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if( components != null )
					components.Dispose();
			}
			base.Dispose( disposing );
		}

		#region Component Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify 
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			this.txtNote = new System.Windows.Forms.TextBox();
			// 
			// txtNote
			// 
			this.txtNote.AcceptsReturn = true;
			this.txtNote.AcceptsTab = true;
			this.txtNote.Location = new System.Drawing.Point(4, 6);
			this.txtNote.Multiline = true;
			this.txtNote.Size = new System.Drawing.Size(224, 120);
			this.txtNote.Text = "";
			this.txtNote.GotFocus += new EventHandler(txtNote_GotFocus);
			// 
			// ctlNoteEntry
			// 
			this.Controls.Add(this.txtNote);
			this.Size = new System.Drawing.Size(236, 152);

		}
		#endregion

		public void LoadSettings()
		{
			if(m_objEntry != null)
			{
                if (!String.IsNullOrEmpty(m_objEntry.NoteText))
                {
                    txtNote.Text = m_objEntry.NoteText;
                }
                else
                {
                    txtNote.Text = "";
                }
			}
		}

		public void SaveSettings()
		{
			if(m_objEntry != null)
			{
				m_objEntry.NoteText = txtNote.Text;
			}
		}

		private void txtNote_GotFocus(object sender, EventArgs e)
		{
			pnlSIP.Enabled = true;
		}
	}
}
